package com.lq.principle.segregation.improve;

public class Segregation1 {
    public static void main(String[] args) {
        A a=new A();
        a.depend1(new B());
        a.depend2(new B());
        a.depend3(new B());
        C c=new C();
        c.depend1(new D());
        c.depend4(new D());
        c.depend5(new D());
    }
}

interface I1{
    void i1();
}
interface I2{
    void i2();
    void i3();
}
interface I3{
    void i4();
    void i5();
}

class A{
    public void depend1(B b){
        b.i1();
    }
    public void depend2(B b){
        b.i2();
    }
    public void depend3(B b){
        b.i3();
    }
}

class B implements I1,I2{

    @Override
    public void i1() {
        System.out.println("B实现了i1方法");
    }

    @Override
    public void i2() {
        System.out.println("B实现了i2方法");
    }

    @Override
    public void i3() {
        System.out.println("B实现了i3方法");
    }

}

class C{
    public void depend1(D d){
        d.i1();
    }
    public void depend4(D d){
        d.i4();
    }
    public void depend5(D d){
        d.i5();
    }
}

class D implements I1,I3{

    @Override
    public void i4() {
        System.out.println("D实现了i4方法");
    }

    @Override
    public void i5() {
        System.out.println("D实现了i5方法");
    }

    @Override
    public void i1() {
        System.out.println("D实现了i1方法");
    }
}